package com.shiguo365.market.presenter.implement;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;
import com.shiguo365.market.presenter.contract.IMainPresenter;
import com.shiguo365.market.display.view.IMainView;

import java.util.List;

import biz.yfsoft.app.aengine.api.AEClient;
import biz.yfsoft.app.aengine.api.AEParam;
import biz.yfsoft.app.aengine.api.BaseAECallback;

public class MainPresenter implements IMainPresenter {

    private static final String TAG = "MainPresenter";

    private final Activity activity;
    private final IMainView mainView;

    public MainPresenter(@NonNull Activity activity, @NonNull IMainView mainView) {
        this.activity = activity;
        this.mainView = mainView;
    }

    @Override
    public void refreshProductListAsyncTask(@NonNull final String tab, @NonNull Integer limit) {

        AEClient _client = new AEClient("shiguo.data.getProductList");
        _client.call(new AEParam().set("type",tab),new BaseAECallback() {

            @Override
            public void onSuccess(List<JSONObject> a) {
                Log.e(TAG,"");
                mainView.onRefreshProductListResultOk(tab, a);
            }

            @Override
            public void onError(String errno, String message) {
                super.onError(errno,message);
                Log.e(TAG,"onFailure ......." + errno);
            }

            @Override
            public void onFinally() {
                mainView.onRefreshProductListFinish();
            }
        });

    }

    @Override
    public void loadMoreProductListAsyncTask(@NonNull String tab, @NonNull Integer page, @NonNull Integer limit) {

    }

    @Override
    public void getUserAsyncTask() {

    }

    @Override
    public void getMessageCountAsyncTask() {

    }


}
